$(document).ready(function(){
	
	$(document).on("click", "#login", function(){
		login();
	});
	
});

function valid(){
	var $validate = $("#loginForm").validate();
	
	return $validate.form()
}

function login(){
	if(valid() === false){
		return;
	}
	
	var param = {
			userName : $("#userName").val(),
			password : $("#password").val(),
			validateCode : $("#validateCode").val(),
			type : $("#type option:selected").val()
	};
	

	
	$.ajax({
		type: "POST",
		url: "login.action",
		data: param,
		dataType: "json",
		success: function(msg){
			alert(msg);
		},
		error: function(msg){
			alert(msg);
		}
	});
	
}